home *** CD-ROM | disk | FTP | other *** search
/ TPUG - Toronto PET Users Group / TPUG Users Group CD / TPUG Users Group CD.iso / CRS / crs47.d81 / bmover.sfx / bmovasm.cvt (.txt) next >
GEOS ConVerT  |  1990-02-12  |  13KB  |  402 lines

  1. B BMovAsm
  2. PRG formatted GEOS file V1.0
  3. Star NX-10
  4. OP V2.0 or higher
  5. BMOVASM
  6. BLASTER'S CONVERTER V2.5
  7. geosMac
  8. BMovHdr.rel
  9. Write Image V2.1
  10. geoWrite    V2.1
  11. ; ****************************************************************************
  12. ;    BMover -- move stuff between banks, call a routine in another bank
  13. ;    Robert A. Knop Jr., Usenet Hacking Mag Issue #2
  14. ;    Note- be sure to set the constants DESTBANK, FIRSTADDR, NUMBLOCKS, etc.
  15. ;        to reflect the moving you want to do.  Be careful NOT to
  16. ;        overlap $ff00!!
  17. ; ****************************************************************************
  18. .if    Pass1
  19. .noeqin
  20.      @.include    geosSym
  21. .include    geosMac
  22. .eqin
  23. .endif
  24. DESTBANK    =    0    ;Bank to copy data to / run routine in (RAM0)
  25. DESTCFG    =    %00111111    ;Config. ($ff00 value) " " " " " " " " " " " "
  26. SRCADDR    =    $0400    ;Source address in FrontRAM ($400=code space)
  27. FIRSTADDR    =    $2000    ;First destination address
  28. NUMBLOCKS    =    $04    ;# of blocks to copy
  29. BLOCKSIZE    =    $2000    ;size of each block copied
  30. BF    =    $80    ;c128 bitmap doubling flags
  31. WLF    =    $8000
  32. WRF    =    $a000
  33. dT    ==    a1    ;ZP variable : dT = time elapsed
  34. dTL    ==    a1L
  35. dTH    ==    a1H
  36. TODTenths    ==    $dc08    ;CIA #1 TOD registers...
  37. TODSecs    ==    $dc09
  38. TODMins    ==    $dc0a
  39. TODHours    ==    $dc0b
  40. Start:    LoadW    r0,Choose3Box
  41.     jsr    DoDlgBox    ;Put up a Dialogue Box selecting the move to do
  42.     CmpBI    r0L,$10
  43.     bne    10$
  44.     jsr    KernalMove
  45.     bra    Start
  46. 10$    cmp    #$11
  47.     bne    90$
  48.     jsr    CallFarRout
  49.     bra    Start
  50.      @jmp    EnterDeskTop
  51. BI_X_0,DBI_Y_2
  52.     .byte    NULL
  53. Yup:    .byte    "Verifcation successful",0
  54. Nope:    .byte    "Verify error!",0
  55.      @Time2Tenths:
  56.     ;Returns CIA #1 TOD since last hour as tenths in r0; hour in r1L
  57.     lda    TODHours
  58.     bpl    10$    ;if AM, no need to convert to 24 hours
  59.     and    #%01111111    ;clear AM/PM flag
  60.     sed        ;TOD is stored in Binary Coded Decimal...
  61.     add    #12    ;Convert to 24 hours
  62.     cld        ;...but otherwise, I know of no use for BCD!!!
  63. 10$    jsr    BCD2binary
  64.     sta    r1L    ;Save starting hour to r1L
  65.     lda    TODMins
  66.     jsr    BCD2binary
  67.     jsr    Mult10
  68.     jsr    Mult60    ;r0=mins*60*10
  69.     MoveW    r0,r2    ;r2 holds minutes (in tenths of secs)
  70.     lda    TODSecs
  71.     jsr    BCD2binary
  72.     jsr    Mult10    ;r0=secs*10
  73.     AddB    TODTenths,r0L    ;Since 10ths<10, BCD is same as binary
  74.     bcc    20$    ; (NOTE: TODTenths MUST be read last!)
  75.     inc    r0H    ;r0 now has 10*secs + tenths
  76. 20$    AddW    r2,r0    ;r0 now has starting time in 10ths of seconds
  77.      @    rts
  78.         ; since the last hour (which is in r1L)
  79.      @StartTime:    
  80. jsr    Time2Tenths
  81.     MoveW    r0,StartT
  82.     MoveB    r1L,StartH
  83.      @rts
  84.      @DeltaT:
  85.     ;Subtract starting time from current time, save as a # of tenths in dT
  86.     jsr    Time2Tenths
  87.     MoveW    r0,dT    ;Save end time in dT
  88.     lda    r1L
  89.     sub    StartH    ;Subtract diffence in hours
  90.     beq    10$    ;if diff., add the diff. to ending time
  91.     jsr    Mult10
  92.     jsr    Mult60
  93.     jsr    Mult60    ;Now hour diff (in tenths of secs) is in r0
  94.     AddW    r0,dT    ;Add this diff to dT
  95. 10$    SubW    StartT,dT    ;Now dT has difference in time
  96.      @    rts
  97.      @PutTime:
  98.     LoadW    r0,TimeBox        ;Writes out dT as a decimal number
  99.     jsr    DoDlgBox
  100.      @rts
  101. TimeBox:
  102.     .byte    DEF_DB_POS|1
  103.     .byte    DB_USR_ROUT
  104.     .word    WriteTime
  105.     .byte    DBTXTSTR
  106.     .byte    TXT_LN_X,TXT_LN_1_Y
  107.     .word    TimeElapsed
  108.     .byte    OK,DBI_X_0,DBI_Y_2    ;OK icon
  109.     .byte    NULL
  110. TimeElapsed:    .byte    "10ths of seconds elapsed:",0
  111. WriteTime:    MoveW    dT,r0    ;Number to write in r0
  112.     LoadW    r11,WLF+DEF_DB_LEFT+TXT_LN_X    ;X position
  113.     LoadB    r1H,DEF_DB_TOP+TXT_LN_3_Y  ;Y position
  114.     lda    #SET_LEFTJUST|SET_SUPRESS     ;Formatting code
  115.     jsr    PutDecimal
  116.      @    rts
  117. BCD2binary:    pha        ;Convert a from BCD to normal binary
  118.     and    #%00001111
  119.     sta    a0L    ;Save lower nybble
  120.     lsr    a
  121.     lsr    a
  122. BCD2binary:    pha        ;Convert a from BCD to normal binary
  123.     and    #%00001111
  124.     sta    a0L    ;Save lower nybble
  125.     lsr    a
  126.     lsr    a
  127.     lsr    a
  128.     lsr    a    ;Shift the upper nybble down to lower nybble
  129.     sta    a0H
  130.     asl    a    ;And multiply by 10
  131.     asl    a
  132.     asl    a
  133.     add    a0H
  134.     adc    a0H
  135.     add    a0L    ;add lower nybble back
  136.      @rts
  137. Mult10:    sta    r0L    ;r0=a*10
  138.     LoadB    r0H,0
  139.     LoadW    r1,10
  140.     ldx    #r0    ;x points to operand1 (and result)
  141.     ldy    #r1    ;y points to operand2
  142.     jsr    DMult
  143.      @rts
  144. Mult60:    LoadW    r1,60    ;r0=r0*60
  145.     ldx    #r0
  146.     ldy    #r1
  147.     jsr    DMult
  148.      @rts
  149.      @KernalMove:
  150.     ;Copies NUMBLOCKS copies of BG screen to DESTBANK
  151.     jsr    StartTime    ;Save starting time
  152.     LoadB    a0L,NUMBLOCKS    ;a0L - a counter in zero page
  153.     LoadW    r0,$6000    ;r0 - source of mo
  154.      @KernalMove:
  155.     ;Copies NUMBLOCKS copies of SRCADDR to DESTBANK
  156.     jsr    StartTime    ;Save starting time
  157.     LoadB    a0L,NUMBLOCKS    ;a0L - a counter in zero page
  158.     LoadW    r0,SRCADDR    ;r0 - source of move
  159.     LoadW    r1,FIRSTADDR    ;r1 - destination of move
  160.     LoadW    r2,BLOCKSIZE    ;r2 - size of move
  161.     LoadB    r3L,1    ;r3L - Source Bank (FrontRAM)
  162.     LoadB    r3H,DESTBANK    ;r3H - Destination Bank
  163. 10$    nop
  164.      @.if    0
  165. jsr    Saver0r3
  166.     ;This is debugging code -- this sort of thing
  167.     LoadW    r0,DBBox
  168.     ; is especially useful since geoDebugger has
  169.     jsr    DoDlgBox
  170.     ; hangups (pun intended) over MoveBData
  171.     jsr    Restr0r3
  172.     ; (sometimes- that's the most infuriating part!)
  173. .endif
  174.     jsr    MoveBData    ; (r0-r3 returned unchanged)
  175.     dec    a0L    ;decrement our counter
  176.     beq    20$    ;If 0, we're done
  177.     AddVW    BLOCKSIZE,r1    ;Point to next block in destination
  178.     bra    10$
  179. 20$    jsr    DeltaT    ;Calculate time elapsed
  180.     jsr    CheckBData    ;Make sure transfers OK
  181.      @jmp    PutTime
  182.     ;Report the time elapsed
  183.      @CheckBData:
  184.     LoadB    a0L,NUMBLOCKS    ;a0L - a counter in zero page
  185.     LoadW    r0,SRCADDR    ;r0 - "source" of verify
  186.     LoadW    r1,FIRSTADDR    ;r1 - "destination" of verify
  187.     LoadW    r2,BLOCKSIZE    ;r2 - size of verify
  188.     LoadB    r3L,1    ;r3L - "Source" Bank (FrontRAM)
  189.     LoadB    r3H,DESTBANK    ;r3H - "Destination" Bank
  190. 10$    jsr    VerifyBData    ; (r0-r3 returned unchanged)
  191.     cpx    #$00    ;Check for verify errors (x=$ff if errors)
  192.     bne    30$
  193.     dec    a0L    ;decrement our counter
  194.     beq    20$    ;If 0, we're done
  195.     AddVW    BLOCKSIZE,r1    ;Point to next 8K in destination
  196.     bra    10$
  197.      @rts
  198. 30$    LoadW    r0,VerErrBox    ;Report verify error
  199.     jsr    DoDlgBox
  200.      @rts
  201. VerErrBox:    .byte    DEF_DB_POS|1
  202.     .byte    DBTXTSTR
  203.     .byte    TXT_LN_X,TXT_LN_1_Y
  204.     .word    VerErrText
  205.     .byte    OK,DBI_X_0,DBI_Y_2
  206.     .byte    NULL
  207. VerErrText:    .byte    "Verify Error in moved data!",0
  208.      @.if    0
  209.         ;A page of debugging code
  210. DBBox:    .byte    DEF_DB_POS
  211.     .byte    DB_USR_ROUT
  212.     .word    PutDBRegs
  213.     .byte    DBTXTSTR,TXT_LN_X,TXT_LN_1_Y
  214. DBStr:    .word    DBText0
  215.     .byte    OK,DBI_X_0,DBI_Y_2
  216.     .byte    NULL
  217. DBText0:    .byte    "About to Move:",0
  218. PutDBRegs:    LoadB    r1H,DEF_DB_TOP+TXT_LN_2_Y
  219.     LoadB    a0L,a2
  220. 10$    LoadW    r11,WLF+DEF_DB_LEFT+TXT_LN_X
  221.     ldx    a0L
  222.     cpx    #a6
  223.     bcs    20$
  224.     lda    $01,x
  225.     jsr    PutHex
  226.     ldx    a0L
  227.     lda    $00,x
  228.     jsr    PutHex
  229.     inc    a0L
  230.     inc    a0L
  231.     AddVB    10,r1H
  232.     bra    10$
  233.      @rts
  234. PutHex:    pha
  235.     lsr    a
  236.     lsr    a
  237.     lsr    a
  238.     lsr    a
  239.     lda    HexNums,x
  240.     jsr    PutChar
  241.     and    #%00001111
  242.     lda    HexNums,x
  243.     jsr    PutChar
  244.      @rts
  245. HexNums:    .byte    "0123456789abcdef"
  246. Saver0r3:    MoveW    r0,a2
  247.     MoveW    r1,a3
  248.     MoveW    r2,a4
  249.     MoveW    r3,a5
  250.     MoveB    a0L,a6L    ;Save the counter!
  251.      @    rts
  252. Restr0r3:    MoveW    a2,r0
  253.     MoveW    a3,r1
  254.     MoveW    a4,r2
  255.     MoveW    a5,r3
  256.     MoveB    a6L,a0L
  257.      @rts
  258.      @.endif
  259.  time elapsed
  260.     jsr    CheckBData    ;Make sure transfers OK
  261.      @jmp    PutTime
  262.     ;Report the time elapsed
  263.      @CheckBData:
  264.      @CallFarRout:
  265.     jsr    StartTime    ;For kicks, time the whole thing
  266.     LoadW    r0,Mover    ;First, install the Mover in DESTBANK
  267.     LoadW    r1,$2000    ; at location $2000
  268.     LoadW    r2,EndMover-Mover
  269.     LoadB    r3L,1    ;FrontRAM
  270.     LoadB    r3H,DESTBANK
  271.     jsr    MoveBData    ;Copy BG screen to $6000 in DESTBANK
  272.     LoadW    r0,$6000    ; (so that it is different from what we put
  273.     LoadW    r1,$6000    ;  at $4000)
  274.     LoadW    r2,$2000
  275.     jsr    MoveBData
  276.     LoadW    r0,$0400    ;Copy this code space etc. to $4000 in DESTBANK
  277.     LoadW    r1,$4000    ; (this we will move using a routine in DESTBANK
  278.     jsr    MoveBData    ;  to $6000 in DESTBANK)
  279.      @sei
  280.         ;Disable interrupts for safety
  281.     ldx    #<(EndZPJSR-ZPJSR-1)
  282. 10$    lda    ZPJSR,x    ;move ZPJSR to $02
  283.     sta    $02,x
  284.     bpl    10$
  285.     .byte    $20,$02,$00    ;jsr $0002
  286.      @cli
  287.         ;Restore interrupts
  288.     jsr    DeltaT    ;Save the end time before the verify check
  289.     LoadW    r0,$0400    ;Make sure that $6000 now matches code space
  290.     LoadW    r1,$6000
  291.     LoadW    r2,$2000
  292.     LoadB    r3L,1
  293.     LoadB    r3H,DESTBANK
  294.     jsr    VerifyBData
  295.     cpx    #$00
  296.     beq    20$    ;x!=$00 means verify error
  297.     LoadW    r0,JsrBox
  298.     jsr    DoDlgBox    ;Report any verify error that has occurred
  299. 20$    jsr    PutTime    ;Report the time it took
  300.      @rts
  301.      @JsrBox:
  302.     .byte    DEF_DB_POS|1
  303.     .byte    DBTXTSTR,TXT_LN_X,TXT_LN_1_Y
  304.     .word    Nope
  305.     .byte    OK
  306.     .byte    DBI_X_0,DBI_Y_2
  307.     .byte    NULL
  308. Nope:    .byte    "Verify error!",0
  309. `8` &H
  310.      @Mover:
  311.     LoadW    r14,$4000    ;Moves 8K at $4000 to $6000
  312.     LoadW    r15,$6000    ;This code is relocated to $2000 in DESTBANK
  313.     ldy    #$00
  314. 10$    lda    (r14),y
  315.     sta    (r15),y
  316.     bne    10$
  317.     inc    r14H
  318.     inc    r15H
  319.     CmpBI    r14H,$80    ;Have we done all 32 pages yet?
  320.     bcc    10$
  321.      @    rts
  322.      @EndMover:
  323.      @ZPJSR:
  324.     lda    $ff00    ;A JSRFAR sort of routine that goes in ZP;
  325.     pha        ;Save initial configuration for later restore
  326.     lda    #DESTCFG
  327.     sta    $ff00
  328.     jsr    $2000    ;jsr to $2000
  329.     sta    $ff00
  330.      @rts
  331. EndZPJSR:
  332. a    ;  to $6000 in DESTBANK)
  333.      @sei
  334.         ;Disable interrupts for safety
  335.     ldx    #<(EndZPJSR-ZPJSR-1)
  336. 10$    lda    ZPJSR,x    ;move ZPJSR to $02
  337.     sta    $02,x
  338.     bpl    10$
  339.     .byte    $20,$02,$00    ;jsr $0002
  340.      @cli
  341.         ;Restore interrupts
  342.     LoadW    r0,$0400    ;M
  343. Choose3Box:    .byte    DEF_DB_POS|1
  344.     .byte    DBTXTSTR    ;
  345.      @Please Select Option
  346.     .byte    TXT_LN_X,2*8
  347.     .word    selOptText
  348.     .byte    DBUSRICON    ;Icon 1
  349.     .byte    BF+2,3*8
  350.     .word    ChIcon1
  351.     .byte    DBTXTSTR    ;...associated text
  352.     .byte    (2+6)*8+7,3*8+10
  353.     .word    ChText1
  354.     .byte    DBUSRICON    ;Icon 2
  355.     .byte    BF+2,6*8
  356.     .word    ChIcon2
  357.     .byte    DBTXTSTR    ;...associated text
  358.     .byte    (2+6)*8+7,6*8+10
  359.     .word    ChText2
  360.     .byte    DBUSRICON    ;Icon 3
  361.     .byte    BF+2,9*8
  362.     .word    ChIcon3
  363.     .byte    DBTXTSTR    ;...associated text
  364.     .byte    (2+6)*8+7,9*8+10
  365.     .word    ChText3
  366.     .byte    NULL
  367. ChIcon1:    .word    ChPic1
  368.     .byte    0,0    ;ignored
  369.     .byte    BF+SYSDBI_WIDTH,SYSDBI_HEIGHT
  370.     .word    ChRout1
  371. ChIcon2:    .word    ChPic2
  372.     .byte    0,0
  373.     .byte    BF+SYSDBI_WIDTH,SYSDBI_HEIGHT
  374.     .word    ChRout2
  375. ChIcon3:    .word    ChPic3
  376.     .byte    0,0
  377.     .byte    BF+SYSDBI_WIDTH,SYSDBI_HEIGHT
  378.     .word    ChRout3
  379. ChRout1:    lda    #$10
  380.     bra    EndCh
  381. ChRout2:    lda    #$11
  382.     bra    EndCh
  383. ChRout3:    lda    #$12
  384. EndCh:    sta    sysDBData
  385.     jmp    RstrFrmDialog
  386. selOptText:    .byte    BOLDON,"Please Select Option:",PLAINTEXT,0
  387. ChText1:    .byte    "repeatedly store BG",0
  388. ChText2:    .byte    "call extrabankal routine",0
  389. ChText3:    .byte    "to DeskTop",0
  390. ChPic1:
  391. ChPic2:
  392. ChPic3:
  393.      @.ramsect
  394. StartH:    .block    1    ;Storage of starting hour
  395. StartT:    .block    2    ;Storage 
  396.      @.ramsect
  397. StartH:    .block    1    ;Storage of starting hour
  398. StartT:    .block    2    ;Storage of starting tenths since last hour
  399. Saved506:    .block    1    ;Temporary storage of MMURCR
  400. da    #SET_LEFTJUST|SET_SUPRESS     ;Formatting code
  401.     jsr    PutDecimal
  402.